
<%@page import="java.util.List"%>
<%@page import="database.DBClass"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="model.Kipmol" %>
<% Kipmol bean;
    bean = new Kipmol();
    //get request from servlet if data is invalid
    if (request.getAttribute("error") != null) {
        bean = (Kipmol) request.getAttribute("error");
    }
    if (request.getAttribute("updateuser") != null) {
        bean = (Kipmol) request.getAttribute("updateuser");
    }
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/kipmol.css">
        <script type="text/javascript" src="JS/show.js"></script>
        <title>KIPEM Online </title>
    </head>
    <body> 
        <div id="main">
            <div id="header">

                <a href="#">
                    <img src="img/Logo_surabaya.gif" id="logo">
                </a>
                <img src="img/kipem.jpg" id="logoText" alt="kipmol">
            </div>

        </div>
        <div id="formpage">
            <div id="welcomeText">
                <p>Selamat Datang di Layanan Registrasi Kartu Identitas Penduduk Online</p>


                <form method="post" action="ControllerServlet">
                    <CENTER>
                        <TABLE border="0" width="662">
                            <TR>
                                <td>Pilih Provinsi</td>
                                <td>
                                    <select name="provinsi" onchange="showKabupaten(this.value)">
                                        <option value="">Pilih Provinsi</option>
                                        <%
                                            DBClass dbobject = new DBClass();
                                            List list = dbobject.getProvinsi();
                                            request.setAttribute("list", list);
                                            List list2 = (List) request.getAttribute("list");
                                            if (list2 != null) {
                                                for (int i = 0; i < list2.size(); i++) {
                                                    Kipmol ubean = (Kipmol) list2.get(i);
                                        %>
                                        <option value="<%=ubean.getIdTabel()%>"><%= ubean.getNamaTabel()%></option>  
                                        <%
                                                }
                                            }
                                        %>
                                    </select> 
                                </td>
                            </tr>

                            <tr>
                                <td>Pilih Kabupaten</td>
                                <td>
                                    <div id='kabupaten'>  
                                        <select name='kabupaten'>
                                            <option value='-1'>Pilih Kabupaten</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td>Pilih Kec</td>
                                <td>
                                    <div id='kecamatan'>  
                                        <select name='kecamatan' >  
                                            <option value='-1'>Pilih Kecamatan</option>  
                                        </select>  
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>Pilih Kelurahan/Desa</td>
                                <td>
                                    <div id='desa'>  
                                        <select name='desa' >  
                                            <option value='-1'>Pilih Desa</option>  
                                        </select>  
                                    </div>
                                </td>
                            </tr>
                            <TR>
                                <TD width="158">Nama Pemohon:</TD>
                                <TD width="144">
                                    <INPUT TYPE="text" NAME="NamaPemohon" value="<%=bean.getNamaPemohon()%>">
                                </TD>
                                <TD width="84">
                                    <font color="red">&nbsp;</font>
                                </TD>
                                <TD width="176">&nbsp;</TD>
                                <TD width="78"><font color="red"><%=bean.getNamaPemohonError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">NIK Pemohon:</TD>
                                <TD>
                                    <INPUT TYPE="text" NAME="NIKPemohon" value="<%=bean.getNIKPemohon()%>">
                                </TD>
                                <TD>&nbsp;</TD>
                                <TD>&nbsp;</TD>
                                <TD><font color="red"><%=bean.getNIKPemohonError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">Nomor Kartu Keluarga:</TD>
                                <TD>
                                    <INPUT NAME="noKKPemohon" TYPE="text" id="noKK" value="<%=bean.getNoKK()%>">
                                </TD>
                                <TD>&nbsp;</TD>
                                <TD>&nbsp;</TD>
                                <TD><font color="red"><%=bean.getNoKKError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">Alamat Asal Pemohon</TD>
                                <TD>
                                    <INPUT NAME="alamatAsal" TYPE="text" id="alamatAsal" value="<%=bean.getAlmtPemohon()%>">
                                </TD>
                                <TD>&nbsp;</TD>
                                <TD>&nbsp;</TD>
                                <TD><font color="red"><%=bean.getAlmtPemohonError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">RT:</TD>
                                <TD>
                                    <INPUT NAME="RTpemohon" TYPE="text" id="RT" value="<%=bean.getRTPemohon()%>">
                                </TD>
                                <TD>RW : </TD>
                                <TD><input name="RWpemohon" type="text" id="RW" value="<%=bean.getRWPemohon()%>"></TD>
                                <TD><font color="red"><%=bean.getRWPemohonError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">Provinsi:</TD>
                                <TD>
                                    <select name='provPemohon' id='provPemohon' onchange="showKotaPemohon(this.value)">  
                                        <option value="none">Select</option>  
                                        <%--<%
                                            Class.forName("com.mysql.jdbc.Driver").newInstance();
                                            Statement stmt1 = con.createStatement();
                                            ResultSet rs1 = stmt1.executeQuery("SELECT * FROM inf_lokasi where lokasi_kabupatenkota=0 and lokasi_kecamatan=0 and lokasi_kelurahan=0 order by lokasi_nama");

                                    while (rs1.next()) {
                                %>
                                <option value="<%=rs1.getString(4)%>"><%=rs1.getString(3)%></option>  
                                <%
                                    }
                                %>--%>
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kota/Kabupaten:</TD>
                                <TD id="KotaPemohon">
                                    <select name='KotaPemohon' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kecamatan:</TD>
                                <TD id="kecPemohon">
                                    <select name='kecPemohon' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kelurahan:</TD>
                                <TD id="kelPemohon">
                                    <select name='kelPemohon' >  
                                        <option value='-1'></option>  
                                    </select> 
                                </TD>
                            </TR>

                            <TR>
                                <TD>Kode Pos</TD>
                                <TD><label>
                                        <input type="text" name="kodepospemohon" id="kodepos">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Nomor Telepon :</TD>
                                <TD><label>
                                        <input type="text" name="noTeleponpemohon" id="noTelepon">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Alasan Tinggal Sementara</TD>
                                <TD><label>
                                        <input name="alasan" type="radio" id="alasan" value="alasanbekerja">
                                        bekerja 
                                        <br>
                                        <input type="radio" name="alasan" id="berdagang" value="alasanberdagang">
                                        berdagang
                                        <br>
                                        <input type="radio" name="alasan" id="pendidikan" value="alasanpendidikan">
                                        pendidikan
                                        <br>
                                        <input type="radio" name="alasan" id="alasanlainnya" value="alasanlainnya">
                                        lainnya : 
                                        <input type="text" name="alasan" id="alasanlainnya2">
                                        <br>
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Alamat yang dituju</TD>
                                <TD><label>
                                        <input type="text" name="alamattujuan" id="alamattujuan">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD width="158">RT:</TD>
                                <TD>
                                    <INPUT NAME="RTtujuan" TYPE="text" id="RT" value="<%=bean.getRTDituju()%>">
                                </TD>
                                <TD>RW : </TD>
                                <TD><input name="RWtujuan" type="text" id="RW" value="<%=bean.getRWDituju()%>"></TD>
                                <TD><font color="red"><%=bean.getRWDitujuError()%></font></TD>
                            </TR>
                            <TR>
                                <TD>Kode Pos</TD>
                                <TD><label>
                                        <input type="text" name="kodepostujuan" id="kodepos">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Nomor Telepon :</TD>
                                <TD><label>
                                        <input type="text" name="noTelepontujuan" id="noTelepon">
                                    </label></TD>
                            <TR>
                                <TD>Nama Orang tua/ wali</TD>
                                <TD><label>
                                        <input type="text" name="namaOrangTua" id="namaOrangTua">
                                    </label></TD>

                            </tr>
                            <tr>
                                <TD>Alamat Orang Tua</TD>
                                <TD><label>
                                        <input type="text" name="alamatOrangTua" id="alamatOrangTua">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD width="158">RT:</TD>
                                <TD>
                                    <INPUT NAME="RT" TYPE="text" id="RTortu" value="<%=bean.getRTOrtu()%>">
                                </TD>
                                <TD>RW : </TD>
                                <TD><input name="RW" type="text" id="RWortu" value="<%=bean.getRWOrtu()%>"></TD>
                                <TD><font color="red"><%=bean.getRWOrtuError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">Provinsi:</TD>
                                <TD>
                                    <select name='provOrtu' id='provOrtu' onchange="showKotaOrtu(this.value)">  
                                        <option value="none">Select</option>  
                                        <%--<%
                                            Class.forName("com.mysql.jdbc.Driver").newInstance();
                                            Statement stmt2 = con.createStatement();
                                            ResultSet rs2 = stmt2.executeQuery("SELECT * FROM inf_lokasi where lokasi_kabupatenkota=0 and lokasi_kecamatan=0 and lokasi_kelurahan=0 order by lokasi_nama");

                                    while (rs2.next()) {
                                %>
                                <option value="<%=rs2.getString(4)%>"><%=rs2.getString(3)%></option>  
                                <%
                                    }
                                %>--%>
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kota/Kabupaten:</TD>
                                <TD id="KotaOrtu">
                                    <select name='KotaOrtu' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kecamatan:</TD>
                                <TD id="kecOrtu">
                                    <select name='kecOrtu' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kelurahan:</TD>
                                <TD id="kelOrtu">
                                    <select name='kelOrtu' >  
                                        <option value='-1'></option>  
                                    </select> 
                                </TD>
                            </TR>
                            <TR>
                                <TD>Kode Pos</TD>
                                <TD><label>
                                        <input type="text" name="kodeposortu" id="kodepos">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Nomor Telepon :</TD>
                                <TD><label>
                                        <input type="text" name="noTeleponortu" id="noTelepon">
                                    </label></TD>
                            <TR>
                                <TD>Nama Penjamin di alamat baru:</TD>
                                <TD><label>
                                        <input type="text" name="namaPenjamin" id="namaPenjamin">
                                    </label></TD>
                            <TR>
                                <TD>Alamat Penjamin</TD>
                                <TD><label>
                                        <input type="text" name="alamatPenjamin" id="alamatPenjamin">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD width="158">RT:</TD>
                                <TD>
                                    <INPUT NAME="RTpenjamin" TYPE="text" id="RT" value="<%=bean.getRTPenjamin()%>">
                                </TD>
                                <TD>RW : </TD>
                                <TD><input name="RWpenjamin" type="text" id="RW" value="<%=bean.getRWPenjamin()%>"></TD>
                                <TD><font color="red"><%=bean.getRWPenjaminError()%></font></TD>
                            </TR>
                            <TR>
                                <TD width="158">Provinsi:</TD>
                                <TD>
                                    <select name='provPenjamin' id='provPenjamin' onchange="showKotaPenjamin(this.value)">  
                                        <option value="none">Select</option>  
                                        <%--<%
                                            Class.forName("com.mysql.jdbc.Driver").newInstance();
                                            Statement stmt3 = con.createStatement();
                                            ResultSet rs3 = stmt3.executeQuery("SELECT * FROM inf_lokasi where lokasi_kabupatenkota=0 and lokasi_kecamatan=0 and lokasi_kelurahan=0 order by lokasi_nama");

                                    while (rs3.next()) {
                                %>
                                <option value="<%=rs3.getString(4)%>"><%=rs3.getString(3)%></option>  
                                <%
                                    }
                                %>--%>
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kota/Kabupaten:</TD>
                                <TD id="KotaPenjamin">
                                    <select name='KotaPenjamin' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kecamatan:</TD>
                                <TD id="kecPenjamin">
                                    <select name='kecPenjamin' >  
                                        <option value='-1'></option>  
                                    </select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="158">Kelurahan:</TD>
                                <TD id="kelPenjamin">
                                    <select name='kelPenjamin' >  
                                        <option value='-1'></option>  
                                    </select> 
                                </TD>
                            </TR>
                            <TR>
                                <TD>Kode Pos</TD>
                                <TD><label>
                                        <input type="text" name="kodepospenjamin" id="kodepos">
                                    </label></TD>
                            </TR>
                            <TR>
                                <TD>Nomor Telepon :</TD>
                                <TD><label>
                                        <input type="text" name="noTeleponpenjamin" id="noTelepon">
                                    </label></TD>

                            <TR>
                                <TD colspan="2" align="center">
                                    <INPUT TYPE="submit" value="<%=bean.getAction()%>" name="action">
                                </TD>
                                <TD>&nbsp;

                                </TD>
                                <TD>&nbsp;</TD>
                                <TD>&nbsp;</TD>
                            </TR>
                        </TABLE>
                    </CENTER>
                </form>
                <form action="LogoutServlet" method="post"> 
                    <INPUT type="submit" value="Logout" name="Logout">
                </form>
            </div>
        </div>
        <div id="footer">
            <p id="footerText">RBPL C- Kelompok 4</p>
        </div>
    </body>
</html>